import { Role } from './Role';
import {
    Entity,
    PrimaryGeneratedColumn,
    Column,
    CreateDateColumn,
    UpdateDateColumn,
    ManyToMany,
    JoinTable,
    ManyToOne,
    JoinColumn
} from "typeorm"
import { Dept } from "./Dept";
@Entity("sys_user")
export class User {
    @PrimaryGeneratedColumn()
    id: number
    @Column()
    username: string
    @Column({
        nullable: true
    })
    nickname: string
    @Column()
    password: string
    @Column(
        {
            nullable: true
        }
    )
    phone: string
    @Column()
    avatar: string
    @Column({
        name: 'data_status',
        nullable: true
    })
    dataStatus: number
    @Column({
        name: "create_time"
    })
    createTime: Date
    @Column({
        name: "update_time"
    })
    updateTime: Date
    @ManyToOne(() => Dept)
    @JoinTable({
        joinColumn: {
            name: 'dept_id'
        }
    })
    dept: Dept
    @ManyToMany(() => Role, role => role.users)
    @JoinTable()
    roles: Role[]
}
